package com.angel.kuaidi.net;

import java.util.HashMap;
import java.util.Map;

import com.angel.kuaidi.KuaidiConstans;

public class RequestEntity {
	private static final String ACCEPT = "application/vnd.wap.xhtml+xml,application/xml,text/vnd.wap.wml,text/html,application/xhtml+xml,image/jpeg;q=0.5,image/png;q=0.5,image/gif;q=0.5,image/*;q=0.6,video/*,audio/*,*/*;q=0.6";
	private static final String ACCEPT_ENCODING = "gzip,deflate";
	private static final String CONNECTION = "Close";
	private static final String METHOD_GET_NAME = "GET";
	private static final String METHOD_POST_NAME = "POST";
	private static final String MODEL = android.os.Build.MODEL;
	private static final String VERSION_RELEASE = android.os.Build.VERSION.RELEASE;
	private static final String USER_AGENT = KuaidiConstans.APP_NAME + "~" + MODEL + "~" + VERSION_RELEASE;

	private String mUrl;
	private byte mMethod;

	private HashMap<String, String> mHeaderMap;
	private HashMap<String, String> mParamsMap;

	public RequestEntity() {
		mHeaderMap = new HashMap<String, String>();
		mParamsMap = new HashMap<String, String>();
		// 缺省 header
		addHeader(HttpHeader.REQ.ACCEPT, ACCEPT);
		addHeader(HttpHeader.REQ.ACCEPT_ENCODING, ACCEPT_ENCODING);
		addHeader(HttpHeader.REQ.CONNECTION, CONNECTION);
		addHeader(HttpHeader.REQ.USER_AGENT, USER_AGENT);
		addHeader(HttpHeader.REQ.user_agent, USER_AGENT);
		addHeader(HttpHeader.REQ.APP_NAME, KuaidiConstans.APP_NAME);// 项目名称
		addHeader(HttpHeader.REQ.VERSION_RELEASE, VERSION_RELEASE);// 手机系统版本
		addHeader(HttpHeader.REQ.MODEL, MODEL);// 手机型号

	}

	public String getUrl() {
		return this.mUrl;
	}

	public void setUrl(String url) {
		this.mUrl = url;
	}

	public void setMethod(byte method) {
		this.mMethod = method;
	}

	public byte getMethod() {
		return this.mMethod;
	}

	public String getMethodName() {
		if (mMethod == NetTask.METHOD_POST)
			return METHOD_POST_NAME;
		else
			return METHOD_GET_NAME;
	}

	public void addParam(String name, String value) {
		mParamsMap.put(name, value);
	}

	public String getParam(String name) {
		return mParamsMap.get(name);
	}

	public void removeParam(String name) {
		mParamsMap.remove(name);
	}

	public Map<String, String> getParams() {
		return this.mParamsMap;
	}

	public void addHeader(String name, String value) {
		mHeaderMap.put(name, value);
	}

	public void getHeader(String name) {
		mHeaderMap.get(name);
	}

	public void removeHeader(String name) {
		mHeaderMap.remove(name);
	}

	public Map<String, String> getHeaders() {
		return this.mHeaderMap;
	}

}
